<?php
	session_start();
	
	require_once('config.php');
	
	
		$connect = new DbConnector();
		
		if($_POST['movement'])
		{
			$movement = $_POST['movement'];
			
			if($movement == 1 || $movement == 0)
			{
				if($movement == 1 || $movement == '1')
				{
					$unix_time = time();
				
					$date_time = date('d/m/Y - H:i:s');
					
					$insert = $connect->query("INSERT INTO ".$TABLES['detection']."(movement, date_time, unix_time) VALUES('".$movement."', '".$date_time."', '".$unix_time."')");
					
					if($insert)
					{
						echo 'Motion detected - '.$date_time;
					}
				}
			}
		}
?>